/*
 * Copyright (C) 2009 M. Hautle.
 * 
 * This file is part of TrackedBean.
 * 
 * TrackedBean is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * TrackedBean is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with TrackedBean. If not, see <http://www.gnu.org/licenses/>.
 */
package ch.trackedbean.validator;

/**
 * Interface describing an object validating a bean property.<br>
 * Implementation must provide a default constructor.<br>
 * <b>A property validator has to be stateless!</b>
 * 
 * @author M. Hautle
 */
public interface IPropertyValidator {
    /**
     * Initializes the validator.<br>
     * You may extract values from the passed configuration.<br>
     * <b>The passed configuration may be reused from the caller so do not store it!</b>
     * 
     * @param cfg The configuration (<b>Do not store it!</b>)
     */
    void init(IPropertyValidatorConfiguration cfg);

    /**
     * Validates the given object.
     * 
     * @param value An object
     * @return Null if the object is valid, otherwise an object describing the error
     */
    IErrorDescription validate(Object value);
}
